Reference for application configuration

You can configure your Kanzi application:

While you can configure your Kanzi application in the onConfigure() function, in application.cfg you can configure some parameters without recompiling your application or even without a C++ application. The configuration you specify in application.cfg overrides the configuration you specify in onConfigure().

For example, in application.cfg you can tell your Kanzi application which .kzb binary to load, enable performance information in your application, and set how many threads you want to use for loading the application resources.

Setting which application.cfg to use

When you have more than one Kanzi application executable file in a directory you can specify a separate configuration file for each executable.

To set which application.cfg to use:

Using the application.cfg

To configure your Kanzi application using application.cfg, create an application.cfg file that contains the parameter names and their values in:

When you launch your Kanzi application, the application uses the parameters in the application.cfg to configure your application.

Setting Description
BinaryName Kzb binary the application loads
DefaultDisplayIndex Default display when running the application in full-screen mode
FPSInfoEnabled Show the performance information
GlyphCacheHeight
GlyphCacheWidth
Size of the glyph cache texture
LoadingThreadCount Loading preferences
MaxPendingResources Maximum number of resources processed by the loading threads
LogVisualizationEnabled Show the Log window
MaximumFPS Maximum FPS
SurfaceBitsStencil
SurfaceBitsDepthBuffer
SurfaceBitsRed
SurfaceBitsGreen
SurfaceBitsBlue
SurfaceBitsAlpha
SurfacePriority
SurfaceSamplesAntialiasing
SurfaceSwapBehavior
Surface properties
UseMemoryMappedLoading Memory mapped loading
WindowStyle Window style of the application
WindowX
WindowY
WindowWidth
WindowHeight
Position and size of the application window

Show the performance information

You can enable the display of Performance HUD that shows the performance information for your Kanzi application. Use Kanzi's Performance HUD to see how your application performs on target devices and to find bottlenecks and areas for improvement.

Performance HUD shows the overall performance indicators of your Kanzi application during the last 300 frames including:

See Best practices.

In application.cfgFPSInfoEnabled = value
In onConfigure()configuration.previewProperties.fpsInfoEnabled = value;
Values
0Disable the display of the Performance HUD. Default value.
1Enable the display of the Performance HUD.
application.cfg example# Enables the Performance HUD in Kanzi application.
FPSInfoEnabled = 1
onConfigure() example// Enables the Performance HUD in Kanzi application.
configuration.previewProperties.fpsInfoEnabled = 1;

Show the Log window

You can enable the printing of the application log messages to the application window.

To display the performance information of your application, see Show the performance information.

In application.cfgLogVisualizationEnabled = value
In onConfigure()configuration.previewProperties.logVisualizationEnabled = value;
Values
0Disable the display of application log in the application window. Default value.
1Enable the display of application log in the application window.
application.cfg example# Enables the display of the application log in the application window.
LogVisualizationEnabled = 1
onConfigure() example// Enables the display of the application log in the application window.
configuration.previewProperties.logVisualizationEnabled = 1;

Size of the glyph cache texture

When you use a Text BlockKanzi creates a glyph cache texture for every font and font size combination. You can set the height and width of glyph cache textures to adjust the size of the glyph cache texture either when it gets full, or to optimize the performance of your Kanzi application.

Because larger glyph cache textures use more VRAM, try different sizes before you set the final size . The upper limit of the glyph cache texture size depends on the GPU, but usually it is 2048 by 2048 pixels. The default size of the glyph cache texture is 512 by 512 pixels.

Kanzi applies the size of the glyph cache texture to all glyph cache textures.

In application.cfgGlyphCacheHeight = size
GlyphCacheWidth = size
In onConfigure()configuration.glyphCacheHeight = size;
configuration.glyphCacheWidth = size;
Values
sizeSize of the glyph cache texture in pixels. The default value is 512.
application.cfg example# Sets the glyph cache texture height to 768, and width to 1024 pixels.
GlyphCacheHeight = 768
GlyphCacheWidth = 1024
onConfigure() example// Sets the glyph cache texture height to 768, and width to 1024 pixels.
configuration.glyphCacheHeight = 768;
configuration.glyphCacheWidth = 1024;

Loading preferences

When users run your Kanzi application in an environment with a multi-core processor, Kanzi automatically uses multiple CPU cores to load the GPU resources in the .kzb files to RAM. See Loading resources in parallel.

GPU resources Kanzi loads in parallel include all types of textures, shaders, and meshes. To deploy these resources from RAM to GPU memory and to load prefab templates, Kanzi always uses the main thread. See Images and textures best practices, Shaders best practices, Meshes best practices.

In application.cfgLoadingThreadCount = threads
In onConfigure()configuration.loadingThreadCount = threads;
Values
threadsNumber of CPU cores used for loading the resources. The default value is 3.
application.cfg example

# Switches off the use of multiple cores for loading your application.
#
Loads your application resources using the main thread.
LoadingThreadCount = 0

# Uses six threads to load your application.
LoadThreadCount = 5

onConfigure() example

// Switches off the use of multiple cores for loading your application.
// Loads your application resources using the main thread.
configuration.loadingThreadCount = 0;

// Uses six threads to load your application.
configuration.loadingThreadCount = 5;

Maximum number of resources processed by the loading threads

You can set the maximum number of resources that the loading threads process at the same time. By increasing the number of resources you can speed up the loading, but at the same time you increase the peak memory use during loading because you can load more resources to the memory before they are deployed to the GPU.

In application.cfgMaxPendingResources = resources
In onConfigure()configuration.maxPendingResources = resources;
Values
resourcesThe maximum number of resources processed at the same time by the loading threads. The default value is 0 and sets the maximum number of resources to the number of loading threads +1.
application.cfg example
# Sets the maximum number of resources processed by the loading
# threads to the number of loading threads + 1. This is the default value.
MaxPendingResources = 0
# Sets the maximum number of resources processed by the loading
# threads to 20 resources.
MaxPendingResources = 20
onConfigure() example
// Sets the maximum number of resources processed by the loading
// threads to the number of loading threads + 1. This is the default value.
configuration.maxPendingResources = 0;
// Sets the maximum number of resources processed by the loading
// threads to 20 resources.
configuration.maxPendingResources = 20;

Surface properties

Surface properties control the properties of the hardware accelerated graphics surface on which Kanzi renders. They control the relation between image quality and rendering speed. The surface properties you set are considered requests to be matched by the graphics system of the target hardware. Whether a given request is considered an upper bound, a lower bound, or an exact value is platform dependent.

The default values of surface properties are platform dependent. You can get them by calling kzsSurfaceGetDefaultProperties().

In application.cfg

SurfaceBitsStencil = stencil
SurfaceBitsDepthBuffer = buffer
SurfaceBitsRed = red
SurfaceBitsGreen = green
SurfaceBitsBlue = blue
SurfaceBitsAlpha = alpha
SurfacePriority = priority
SurfaceSamplesAntialiasing = anti
SwapBehavior = swap

In onConfigure()configuration.defaultSurfaceProperties.bitsStencil = stencil;
configuration.defaultSurfaceProperties.bitsDepthBuffer = buffer;
configuration.defaultSurfaceProperties.bitsColorR = red;
configuration.defaultSurfaceProperties.bitsColorG = green;
configuration.defaultSurfaceProperties.bitsColorB = blue;
configuration.defaultSurfaceProperties.bitsAlpha = alpha;
configuration.defaultSurfaceProperties.antiAliasing = anti;
configuration.defaultSurfaceProperties.priority = priority;
configuration.defaultSurfaceProperties.swapBehaviorCopy = swap;
Values
stencilSize of the stencil buffer in bits.
bufferSize of the depth buffer in bits.
redSize of the red color channel in bits.
greenSize of the green color channel in bits.
blueSize of the blue color channel in bits.
alphaSize of the alpha channel in bits.
antiNumber of anti-aliasing samples used.
priority

Surface priority is a hint you can use in graphics context initialization:

  • Disable surface priority setting (default value): KZS_SURFACE_PROPERTY_DONT_CARE
  • High priority:
    • String: EGL_CONTEXT_PRIORITY_HIGH_IMG
    • Hexadecimal: 0x3101 (only in onConfigure())
    • Decimal: 12545
  • Medium priority:
    • String: EGL_CONTEXT_PRIORITY_MEDIUM_IMG
    • Hexadecimal: 0x3102 (only in onConfigure())
    • Decimal: 12546
  • Low priority:
    • String: EGL_CONTEXT_PRIORITY_LOW_IMG
    • Hexadecimal: 0x3103 (only in onConfigure())
    • Decimal: 12547
swapDuring the swap buffer, are the buffers swapped or copied. Use 1 for copy, 0 for swap, KZS_SURFACE_PROPERTY_DONT_CARE for automatic selection. Default value is 0 (swap).
application.cfg example

# An example configuration for a typical high-speed rendering application.
SurfaceBitsStencil = 1
SurfaceBitsDepthBuffer = 16
SurfaceBitsRed = 5
SurfaceBitsGreen = 6
SurfaceBitsBlue = 5
SurfaceBitsAlpha = 0
SurfaceSamplesAntialiasing = 0

# An example configuration for a high image quality application.
SurfaceBitsStencil = 8
SurfaceBitsDepthBuffer = 24
SurfaceBitsRed = 8
SurfaceBitsGreen = 8
SurfaceBitsBlue = 8
SurfaceBitsAlpha = 8
SurfaceSamplesAntialiasing = 4

# An example configuration for setting the surface priority to high (EGL_CONTEXT_PRIORITY_HIGH_IMG) on Integrity WSEGL no-usermem build.
SurfacePriority = 12545

onConfigure() example

// An example configuration for a typical high-speed rendering application.
configuration.defaultSurfaceProperties.bitsStencil = 1;
configuration.defaultSurfaceProperties.bitsDepthBuffer = 16;
configuration.defaultSurfaceProperties.bitsColorR = 5;
configuration.defaultSurfaceProperties.bitsColorG = 6;
configuration.defaultSurfaceProperties.bitsColorB = 5;
configuration.defaultSurfaceProperties.bitsAlpha = 0;
configuration.defaultSurfaceProperties.antiAliasing = 0;

// An example configuration for a high image quality application.
configuration.defaultSurfaceProperties.bitsStencil = 8;
configuration.defaultSurfaceProperties.bitsDepthBuffer = 24;
configuration.defaultSurfaceProperties.bitsColorR = 8;
configuration.defaultSurfaceProperties.bitsColorG = 8;
configuration.defaultSurfaceProperties.bitsColorB = 8;
configuration.defaultSurfaceProperties.bitsAlpha = 8;
configuration.defaultSurfaceProperties.antiAliasing = 4;

// An example configuration for setting the surface priority to high (EGL_CONTEXT_PRIORITY_HIGH_IMG) on Integrity WSEGL no-usermem build.
configuration.defaultSurfaceProperties.priority = 0x3101;

Default display when running the application in full-screen mode

When you run your Kanzi application in full-screen mode on a system with more than one display, you can set the default display where your Kanzi application window appears.

Note that in order to use the default application display, you have to set the window style of your Kanzi application to full-screen. See Window style of the application and KzsWindowProperties.

In application.cfgDefaultDisplayIndex = index
In onConfigure()configuration.defaultDisplayIndex = index;
Value
indexIndex number of the display. Default value is 0.
application.cfg example# Sets the second display as the default display for the full-screen Kanzi application window.
DefaultDisplayIndex = 1
onConfigure() example// Sets the second display as the default display for the full-screen Kanzi application window.
configuration.defaultDisplayIndex = 1;

Position and size of the application window

You can set the position of the application on the screen relative to the upper-left corner of the screen and the size of the application window in pixels. The default size of the window is 640x480 pixels and center of the device screen.

To change the style of the window, see Window style of the application.

In application.cfgWindowX = positionX
WindowY = positionY
WindowWidth = width
WindowHeight = height
In onConfigure()configuration.defaultWindowProperties.x = positionX;
configuration.defaultWindowProperties.y = positionY;
configuration.defaultWindowProperties.width = width;
configuration.defaultWindowProperties.height = height;
Value
positionXHorizontal position of the top-left corner of the application window from the top-left corner of the screen in pixels. Use 0 to position the window to the left of the device screen.
positionYVertical position of the top-left corner of the application window from the top-left corner of the screen in pixels. Use 0 to position the window to the top of the device screen.
widthWindow width in pixels.
heightWindow height in pixels.
application.cfg example

# Set the width to 1280 and height to 720 pixels and place it 100 pixels
# from the top and 1 pixel from the left side of the device screen.
WindowWidth = 1280
WindowHeight = 720
WindowX = 100
WindowY = 1

# Place the application window in the top-left corner of the device screen.
WindowX = 0
WindowY = 0

onConfigure() example

# Set the width to 1280 and height to 720 pixels and place it 100 pixels
# from the top and 1 pixel from the left side of the device screen.
configuration.defaultWindowProperties.width = 1280;
configuration.defaultWindowProperties.height = 720;
configuration.defaultWindowProperties.x = 100;
configuration.defaultWindowProperties.y = 1;

# Place the application window in the top-left corner of the device screen.
configuration.defaultWindowProperties.x = 0;
configuration.defaultWindowProperties.y = 0;

Memory mapped loading

When running your Kanzi application on an operating system that supports memory mapping of files, you can enable memory mapped loading for the .kzb files your Kanzi application uses. When you enable memory mapped loading you can reduce the loading times of your Kanzi application because it reduces the amount of file accesses.

Memory mapping of files is supported, for example, on Windows, Linux, and QNX operating systems. Before enabling memory mapped loading, check that it is supported on the platform running your Kanzi application.

To check whether memory mapped loading is supported on your platform, call the kzsMemoryMappedFileIsSupported() function. The function returns True if memory mapped loading is supported, and False if it is not supported.

If you enable memory mapped loading on a platform that does not support this feature, Kanzi shows a warning and uses regular file access for loading the .kzb files.

In application.cfgUseMemoryMappedLoading = value
In onConfigure()configuration->useMemoryMappedLoading = value;
Values
0Disable the memory mapped loading. Default value.
1Enable the memory mapped loading.
application.cfg example# Enables the memory mapped loading for the .kzb files in your Kanzi application.
UseMemoryMappedLoading = 1
onConfigure() example// Enables the memory mapped loading for the .kzb files in your Kanzi application.
configuration.useMemoryMappedLoading = 1;

Window style of the application

You can set the style of the window of your Kanzi application. Besides the default window with a border that users can resize, you can set your Kanzi application to launch in a window without a border, in a window of fixed size, and in a window that occupies the entire device screen.

To set the position and size of the application window, see Position and size of the application window.

In application.cfgWindowStyle = "style"
In onConfigure()configuration.defaultWindowProperties.style = style;
Value
style

Window style (onConfigure values in parenthesis):

application.cfg example

# Launch the application in a window that occupies the whole screen of the device.
WindowStyle = "fullscreen"

onConfigure() example// Launch the application in a window that occupies the whole screen of the device.
configuration.defaultWindowProperties.style = KZS_WINDOW_STYLE_FULL_SCREEN;

Maximum FPS

You can limit the number of frames rendered per second by setting the maximum frame rate. See Show the performance information.

In application.cfgMaximumFPS = limit
In onConfigure()configuration.fpsConstraints.enabled = value;
configuration.fpsConstraints.maximumFPS = limit;
Value
limitThe maximum frame rate of the application in frames per second.
value0 disables the limit, 1 enables the limit. Required only when configuring in onConfigure().
application.cfg example

# Sets the maximum application frame rate to 32 frames per second.
MaximumFPS = 32

# Disables the limit.
MaximumFPS = 0

onConfigure() example

// Enables the setting of the FPS limit
configuration.fpsConstraints.enabled = 1;
// Sets the maximum application frame rate to 32 frames per second.

configuration.fpsConstraints.maximumFPS = 32;

// Disables the limit.
configuration.fpsConstraints.enabled = 0;

Kzb binary the application loads

You can set which .kzb binary or binary configuration file your Kanzi application loads when a you launch your Kanzi application.

See Using .kzb binaries.

In application.cfgBinaryName = "name"
In onConfigure()configuration.binaryName = "name";
Value
namePath to a single .kzb binary, or to the binary configuration file listing all .kzb files that your Kanzi application loads.
application.cfg example

# Loads the .kzb binary named MyApplication.kzb.
BinaryName = "MyApplication.kzb"

# Loads the binary configuration file MyApplicationKzbs.cfg that lists
# all .kzb files that your Kanzi application loads.
BinaryName = "MyApplication.kzb.cfg"

onConfigure() example

// Loads .kzb binary named MyApplication.kzb.
configuration.binaryName = "MyApplication.kzb";

// Loads the binary configuration file MyApplicationKzbs.cfg that lists
// all .kzb files that your Kanzi application loads.
configuration.binaryName = "MyApplication.kzb.cfg";

See also

Best practices

Loading resources in parallel

Using .kzb binaries